import apiClient from '../apiClient';

const getFrontApi = (uri: string, params: any) =>
  apiClient.get<any>({ url: `/front/${uri}`, params });
const getListApi = (uri: string, params: any) =>
  apiClient.get<any>({ url: `/member/${uri}/page`, params });
const getCustomApi = (uri: string, params: any, config?: any) =>
  apiClient.get<any>({ url: `${uri}`, params, ...config });
const postCustomApi = (uri: string, data: any) => apiClient.post<any>({ url: `${uri}`, data });
const putCustomApi = (uri: string, data: any) => apiClient.put<any>({ url: `${uri}`, data });
const getApi = (uri: string, params: any) =>
  apiClient.get<any>({ url: `/member/${uri}/detail`, params });

const addApi = (uri: string, data: any) => apiClient.post<any>({ url: `/member/${uri}/add`, data });
const editApi = (uri: string, data: any) =>
  apiClient.put<any>({ url: `/member/${uri}/edit`, data });
const setStatusApi = (uri: string, data: any) =>
  apiClient.put<any>({ url: `/member/${uri}/status`, data });
const delApi = (uri: string, params: any) =>
  apiClient.delete<any>({ url: `/member/${uri}/delete`, params });
const collectApi = (uri: string, params: any) =>
  apiClient.get<any>({ url: `/member/${uri}/putToCollect`, params, withCredentials: true });
const addCartApi = (params: any) =>
  apiClient.get<any>({ url: '/member/cart/putOneToCart', params, withCredentials: true });

const uploadApi = (data: any) =>
  apiClient.post<any>({
    url: `/common/upload`,
    data,
    headers: { 'Content-Type': 'multipart/form-data' },
  });
const getBaseApi = () => apiClient.get<any>({ url: `/common/baseProperty/getAllProperty` });

export default {
  getFrontApi,
  getListApi,
  getApi,
  delApi,
  addApi,
  editApi,
  collectApi,
  getCustomApi,
  postCustomApi,
  putCustomApi,
  setStatusApi,
  uploadApi,
  getBaseApi,
  addCartApi,
};
